import type { CategoryList } from "./categoryModel";
import type { UploadUserFile } from "element-plus";

export interface GetSpuListParams {
  page: number;
  limit: number;
  category3Id: number;
}

/*
  {
    "records": [
      {
        "id": 4603,
        "spuName": "223",
        "description": "4322",
        "category3Id": 1,
        "tmId": 18226,
        "spuSaleAttrList": null,
        "spuImageList": null
      }
    ],
    "total": 2,
    "size": 1,
    "current": 1,
    "searchCount": true,
    "pages": 2
  }
*/

export interface SpuItem {
  id: number;
  // SPU名称
  spuName: string;
  // SPU描述
  description: string;
  // 三级分类Id
  category3Id: number;
  tmId: number;
  spuSaleAttrList: null;
  spuImageList: null;
}

export type SpuList = SpuItem[];

export interface GetSpuListResponse {
  records: SpuList;
  total: number;
  size: number;
  current: number;
  searchCount: boolean;
  pages: number;
}

export type BaseSaleAttrList = CategoryList;

// 公用的参数类型
/* 
  {
    "category3Id": 0,
    "description": "string",
    "id": 0,
    "spuImageList": [
      {
        "id": 0,
        "imgName": "string",
        "imgUrl": "string",
        "spuId": 0
      }
    ],
    "spuName": "string",
    "spuSaleAttrList": [
      {
        "baseSaleAttrId": 0,
        "id": 0,
        "saleAttrName": "string",
        "spuId": 0,
        "spuSaleAttrValueList": [
          {
            "baseSaleAttrId": 0,
            "id": 0,
            "isChecked": "string",
            "saleAttrName": "string",
            "saleAttrValueName": "string",
            "spuId": 0
          }
        ]
      }
    ],
    "tmId": 0
  }

*/

export interface spuSaleAttrValueItem {
  baseSaleAttrId: number;
  id?: 0;
  saleAttrValueName: string;
  spuId?: 0;
}

export type spuSaleAttrValueList = spuSaleAttrValueItem[];

export interface AllSpuSaleAttrItem {
  baseSaleAttrId: number;
  id?: 0;
  saleAttrName: string;
  spuId?: 0;
  isShowEdit: boolean;
  spuSaleAttrValueList: spuSaleAttrValueList;
}

export type AllSpuSaleAttrList = AllSpuSaleAttrItem[];

export interface AllSpuImageItem {
  imgName: string;
  imgUrl: string;
  isDefault?: string;
}

export type AllSpuImageList<T = AllSpuImageItem | UploadUserFile> = Array<T>;

export interface AllSpuItem<T = AllSpuImageItem | UploadUserFile> {
  spuName: string;
  description: string;
  tmId: undefined | number;
  category3Id?: number;
  id?: number;
  spuImageList: AllSpuImageList<T>;
  spuSaleAttrList: AllSpuSaleAttrList;
}
